<?php

use yii\db\Migration;

class m170607_020220_alert_art_teaching extends Migration
{
    private function createDbs(){
        $dbs = [];
        $dbs_info =\Yii::$app->params['db'];
        foreach($dbs_info as $k=>$v){
            $dbs[$k] = \Yii::createObject($v);
        }
        return $dbs;
    }
    public function safeUp()
    {
        $dbs = $this->createDbs();
        foreach ($dbs as $v) {
            $this->db = $v;
            $this->addColumn('{{%art_teaching}}', 'max_count', $this->smallInteger(3) . ' default 0 comment \'最大人数\'');
            $this->addColumn('{{%art_teaching}}', 'star_time', $this->string(10) . ' default null comment \'开始时间\'');
            $this->addColumn('{{%art_teaching}}', 'end_time', $this->string(10) . ' default null comment \'结束时间\'');
            $this->addColumn('{{%art_teaching}}', 'mechainc_id', $this->integer(11) . ' default 0 comment \'机构\'');
        }
    }

    public function safeDown()
    {
        $dbs = $this->createDbs();
        foreach ($dbs as $v) {
            $this->db = $v;
            $this->dropColumn('{{%art_teaching}}', 'max_count');
            $this->dropColumn('{{%art_teaching}}', 'star_time');
            $this->dropColumn('{{%art_teaching}}', 'end_time');
            $this->dropColumn('{{%art_teaching}}', 'mechainc_id');
        }
    }
}
